<template>
  <div
    class="list"
    :style="{ background: 'url(' + playlist.coverImgUrl + ') ' }"
  >
    <div class="list-head" v-show="!isLoading">
      <div class="list-head-img">
        <img :src="playlist.coverImgUrl" alt="" />
        <span><van-icon name="play-circle-o" />{{ playlist.playCount }}</span>
      </div>
      <div class="list-head-text">
        <span>{{ playlist.name }}</span>
        <div>
          <img :src="playlist.creator.avatarUrl" alt="" />{{
            playlist.creator.nickname
          }}
        </div>
        <div>
          {{ playlist.description }}
        </div>
      </div>
    </div>

    <div class="fenx">
      <van-button size="small" icon="share-o" round type="primary"
        >分享给好友</van-button
      >
    </div>

    <div class="list-music">
      <div class="list-music-head">
        <van-icon name="play-circle-o" />
        <h2>播放全部</h2>
        <p>(共{{ playlist.trackCount }}首)</p>
      </div>

      <div class="list-music-item">
        <div
          v-for="(item, index) in playlist.tracks"
          :key="index"
          @click="gosongDetail(item.id)"
        >
          <div class="luyou">
            <div class="jishu">{{ index + 1 }}</div>

            <div class="list-music-song">
              <h3>{{ item.name.substr(0, 15) + "..." }}</h3>

              <div>
                <!-- <img src="../assets/dujia.png" alt="" />
                     <img src="../assets/sq.png" alt="" /> -->
                {{ item.ar[0].name }}-{{ item.name.substr(0, 8) }}....
              </div>
            </div>

            <div class="you"><van-icon name="play-circle-o" /></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { loadCateAPI } from "../../api/home";
export default {
  name: "list",
  data() {
    return {
      isLoading: true,
      playlist: {
        coverImgUrl: "",
        creator: {
          avatarUrl: "",
        },
      },
      privileges: [],
    };
  },
  created() {
    this.load();
  },
  methods: {
    async load() {
      const respai = await loadCateAPI(this.$route.query.id);
      if (respai.data.code == "200") {
        // console.log(respai);
        this.playlist = respai.data.playlist;
        this.privileges = respai.data.privileges;
        this.isLoading = false;
      }
    },
    gosongDetail(id) {
      // console.log(id);
      this.$router.push(`/songdetail/${id}`);
    },
  },
};
</script>

<style scoped>
.luyou {
  display: flex;
  padding-bottom: 30px;
}
.list {
  display: flex;
  flex-direction: column;
}
.dd {
  height: 50px;
}
.list-head {
  padding-top: 50px;
  display: flex;
  margin: 15px;
}
.list-head-img {
  width: 132px;
  height: 132px;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
  margin-right: 21px;
}
.list-head-img img {
  width: 100%;
  height: 100%;
}
.list-head-img span {
  position: absolute;
  right: 4px;
  top: 4px;
  color: white;
  font-size: 13px;
}
.list-head-text {
  flex: 1;
  color: #f0f2f7;
}
.list-head-text div:nth-child(1) {
  color: white;
  font-size: 17px;
}
.list-head-text div:nth-child(2) {
  font-size: 12px;
  margin: 10px 0;
  display: flex;
  align-items: center;
}
.list-head-text div:nth-child(2) img {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  margin-right: 7px;
}
.list-head-text div:nth-child(3) {
  line-height: 16px;
  font-size: 11px;
}
.fenx {
  display: flex;
  justify-content: center;
}

.list-music {
  background: #fff;
  border-radius: 25px 25px 0px 0px;
  margin-top: 20px;
  padding: 15px;
}
.list-music-head {
  height: 25px;
  display: flex;
  align-items: center;
}
.list-music-head h2 {
  font-size: 15px;
  margin: 0 4px;
  font-weight: normal;
}
.list-music-head p {
  color: #b2b2b2;
  font-size: 13px;
}
.list-music-item {
  display: flex;
  flex-direction: column;
  margin: 35px 16px 33px 0;
  align-items: center;
  color: #959595;
}
.list-music-top {
  width: 27px;
  font-size: 25px;
  line-height: 15px;
}
.list-music-song {
  flex: 1;
}
.list-music-song h3 {
  font-size: 14px;
  color: black;
  font-weight: normal;
  width: 70vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-music-song div {
  font-size: 10px;
  color: #000;
  align-items: center;
}
.list-music-song div img {
  width: 16px;
  height: 10px;
  margin-right: 5px;
}
.list-music-item .jishu {
  line-height: 34px;
  color: #000;
  margin: 0 10px;
}
.you {
  float: right;
  line-height: 34px;
  color: #000;
}
</style>
